package com.ctg.itrdc.sysmgr.portal.service.aop;

import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import com.ctg.itrdc.pasp.core.DTO;
import com.ctg.itrdc.sysmgr.portal.api.dto.BaseDTO;
import com.ctg.itrdc.sysmgr.portal.service.utils.DTOHelper;

@Aspect
@Component
public class DTOAOP {

	protected Logger logger = LoggerFactory.getLogger(this.getClass());

	@Pointcut(value = "execution(* insert(..))"
			+ "|| execution(* updateByPrimaryKey(..))")
	private void pointcut() {
	}

	@Before(value = "pointcut() && args(args)")
	public void dtoIntercepter(Object args) {
		if(args instanceof BaseDTO){
			DTOHelper.updateDTO((BaseDTO) args);
		}
	}

}
